﻿@using PlatformNetCore.Entity

@model CustomerInfo

<div class="banner banner-about" style="background-image:url(@(Model.Ad != null && !string.IsNullOrWhiteSpace(Model.Ad.AdImagePC) ? Model.Ad.AdImagePC:"/img/banner/service.jpg"))">
    <div class="txt">
        <div class="nav-container">
            <h1 class="text28 wow fadeInUp">@ViewBag.ParentTitle</h1>
            <ul class="nav wow fadeInUp">
                @foreach (Menu item in ViewBag.MenuTopSecond)
                {
                    <li><a href="@item.Link" class="@(item.MenuCode.Equals(ViewBag.MenuCode)?"active":"")">@item.Title</a></li>
                }
            </ul>
        </div>
    </div>
</div>

<div class="page page-comments">
    <div class="formMessage">
        <form id="commentForm" action="/comment" method="post">
            <div class="row form-group wow fadeInUp">
                <div class="col-lg-2">
                    <label for="name">联系人*</label>
                </div>
                <div class="col-lg-10">
                    <input class="form-control" type="text" id="Person" name="Person" placeholder="联系人">
                </div>
            </div>
            <div class="row form-group wow fadeInUp">
                <div class="col-lg-2">
                    <label for="name">联系方式*</label>
                </div>
                <div class="col-lg-10">
                    <input class="form-control" type="text" id="Phone" name="Phone" placeholder="联系方式">
                </div>
            </div>
            <div class="row form-group wow fadeInUp">
                <div class="col-lg-2">
                    <label for="name">邮箱*</label>
                </div>
                <div class="col-lg-10">
                    <input class="form-control" type="text" id="Email" name="Email" placeholder="邮箱">
                </div>
            </div>
            <div class="row form-group wow fadeInUp">
                <div class="col-lg-2">
                    <label for="name">留言标题*</label>
                </div>
                <div class="col-lg-10">
                    <input class="form-control" type="text" id="Title" name="Title" placeholder="留言标题">
                </div>
            </div>
            <div class="row form-group wow fadeInUp">
                <div class="col-lg-2">
                    <label for="name">留言内容*</label>
                </div>
                <div class="col-lg-10">
                    <textarea class="form-control" id="Content" name="Content" maxlength="500" rows="5" placeholder="留言内容"></textarea>
                </div>
            </div>
            <div class="form-action wow fadeInUp">
                <button class="btn btn-primary btn-radius" type="button" id="btnSubmit">提交</button>
            </div>
        </form>
    </div>
</div>
@section scripts{
    <script src="~/layui/layui.js"></script>
    <script src="~/js/jquery-1.10.2.min.js"></script>
    <script>
        layui.use(['layer'], function () {
            var $ = layui.$;
            layer = layui.layer;

            $("#btnSubmit").click(function () {
                var Person = $("#Person").val();
                if (!Person) {
                    layer.msg("联系人不能为空！", { icon: 0, time: 1500 });
                    return;
                }
                var Phone = $("#Phone").val();
                if (!Phone) {
                    layer.msg("联系方式不能为空！", { icon: 0, time: 1500 });
                    return;
                }
                var Email = $("#Email").val();
                if (!Email) {
                    layer.msg("邮箱不能为空！", { icon: 0, time: 1500 });
                    return;
                }
                var Title = $("#Title").val();
                if (!Title) {
                    layer.msg("留言标题不能为空！", { icon: 0, time: 1500 });
                    return;
                }
                var Content = $("#Content").val();
                if (!Content) {
                    layer.msg("留言内容不能为空！", { icon: 0, time: 1500 });
                    return;
                }
                // 正则验证格式
                var reg = /^([a-zA-Z0-9_\.\-])+\@@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                if (!reg.test(Email)) {
                    layer.msg("请输入有效的邮箱！", { icon: 0, time: 1500 });
                    return;
                }
                $.post('/comment', $("#commentForm").serialize(), function (res) {
                    if (res.success) {
                        document.getElementById("commentForm").reset();
                        layer.msg("提交成功！", { icon: 1, time: 1500 });
                    }
                    else {
                        layer.msg("提交失败！", { icon: 1, time: 1500 });
                    }
                });
            });
        });
    </script>
}
